package com.controller;

import com.mapper.*;
import com.pojo.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class DispatcherHandler {
    @RequestMapping("{folder}/{page}/index")
    public String  index(@PathVariable String folder,@PathVariable String page){
        return folder+"/"+page;
    }

    @Resource
    private BranchMapper branchMapper;
    @Resource
    private HospitalMapper hospitalMapper;
    @Resource
    private DepartmentMapper departmentMapper;
    @Resource
    private RoleMapper roleMapper;
    @Resource
    private MenuMapper menuMapper;
    @Resource
    private WarehouseMapper warehouseMapper;
    @Resource
    private GoodsSortMapper goodsSortMapper;
    @Resource
    private GooallMapper gooallMapper;
    @ModelAttribute
    public void init(Model model){
        List<Role> roles=roleMapper.list();
        List<Hospital> hospitals=hospitalMapper.list();
        List<Department> departments=departmentMapper.list();
        List<Branch> branchs=branchMapper.list();
        List<Menu> menus=menuMapper.searchLevel01();
        List<Warehouse> warehouses=warehouseMapper.list();
        List<GoodsSort> goodsSorts=goodsSortMapper.list();
        List<Gooall> gooalls=gooallMapper.list();
        model.addAttribute("warehouses",warehouses);
        model.addAttribute("roles",roles);
        model.addAttribute("hospitals",hospitals);
        model.addAttribute("departments",departments);
        model.addAttribute("branchs",branchs);
        model.addAttribute("menus",menus);
        model.addAttribute("goodsSorts",goodsSorts);
        model.addAttribute("gooalls",gooalls);
    }
}
